<?php


namespace app\opengzh\controller;


use app\common\model\Article;
use app\common\model\GzhAccount;
use app\common\model\GzhTitle;
use app\common\model\Swiper;
use app\opengzh\BaseController;
use app\opengzh\service\DeepSeekService;
use app\opengzh\service\OpenPlatformService;
use think\facade\Request;


class OpenPlatform extends BaseController {


    //draft 新建草稿
    public function draft(){
        $appid = $this->request->param('appid');
        $opfService =  new OpenPlatformService();
        $titleModel = new GzhTitle();
        $list = $titleModel
            ->where('is_article',2)
            ->where('is_caogao',1)
            ->order('id','asc')
            ->limit(1)
            ->select()
            ->toArray();
        if(sizeof($list)>0){
            foreach ($list as $v){
                $articleModel = new Article();
                $article_info = $articleModel->where('title_id',$v['id'])->find()->toArray();
                $res = $opfService->draft($appid,$article_info['content2'],$v);
                if($res['status']){
                    return json(msuc($res['msg']));
                }else{
                    return json(merr($res['msg']));
                }
            }
        }


    }

}

